<?php
/**
 * 消息队列消费服务
 */
namespace app\service;
use app\api\controller\v1\Mail;
use think\Db;
use think\Log;
class QueuesSendEmail
{
	/**
	 * 发送邮件
	 */
	public function send_email_try(\think\queue\Job $job, $queues_data)
	{
		//删作队列
		$job->delete();
        $result = Mail::mailTo($queues_data['to'],$queues_data['title'],$queues_data['content']);
        if ($result['code'] == 0){
//            log::write($result['msg']);
            $job = "app\service\QueuesSendEmail@send_email";
            //延时时间
            $delayed_second = 10;
            $queues_data = ['to' => $queues_data['to'],'title'=>$queues_data['title'],'content'=>$queues_data['content']];
            \think\Queue::later($delayed_second, $job, $queues_data, 'send_email');
        }
	}

	
}